<template>
  <div>
    <CityHeader></CityHeader>
    <Search :cities="cities"></Search>
    <List :cities="cities" :hot="hotCities" :letter="letter"></List>
    <Alphabet :cities="cities" @change="handleLetterChange"></Alphabet>
  </div>
</template>

<script>
import axios from "axios";
import CityHeader from "@/pages/city/components/CityHeader";
import Search from "@/pages/city/components/Search";
import List from "@/pages/city/components/List";
import Alphabet from "@/pages/city/components/Alphabet";
export default {
  data() {
    return {
        cities:{},
        hotCities:[],
        letter:""
    };
  },
  components: {
    CityHeader,
    Search,
    List,
    Alphabet
  },
  created() {},
  methods: {
    getCityInfo() {
      axios.get("/static/mock/city.json").then(this.handleGetCityInfoSucc);
    },
    handleGetCityInfoSucc(res) {
      res = res.data;
      console.log(res.data);
      if (res.ret && res.data) {
        const data = res.data;
        this.cities = data.cities;
        this.hotCities = data.hotCities;
      }
    },
    handleLetterChange(letter) {
      console.log(letter);
      this.letter = letter;
    }
  },
  mounted() {
    this.getCityInfo();
  }
};
</script>

<style scoped>
</style>
